{include file="public/layout" /}

<body class="bodystyle" style="overflow-y: scroll;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="shop/left" /}
<div class="page">
    <div class="flexigrid">
        <form class="form-horizontal" id="post_form" action="{:url('Shop/conf')}" method="post">
            <div class="hDiv">
                <div class="hDivBox">
                    <table cellspacing="0" cellpadding="0" style="width: 100%">
                        <thead>
                        <tr>
                            <th class="sign w10" axis="col0">
                                <div class="tc"></div>
                            </th>
                            <th abbr="article_title" axis="col3" class="w10">
                                <div class="tc">基本设置</div>
                            </th>
                            <th abbr="ac_id" axis="col4">
                                <div class=""></div>
                            </th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="ncap-form-default">
                <dl class="row">
                    <dt class="tit">标签调用</dt>
                    <dd class="opt">
                        <a href="javascript:void(0);" onclick="tag_call('shop_open');" class="ncap-btn ncap-btn-green">查看标签</a>
                        <p class="notic">请确保商城模板已经调用购买行为的标签，里面包含规格、数量、价格等！</p>
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit">
                        <label for="uname">商家提示</label>
                    </dt>
                    <dd class="opt">
                        <textarea name="shop[shop_prompt]" placeholder="此处文字将显示在会员下单确认页面上" style="width: 30%; height: 60px;">{$userConfig.shop_prompt}</textarea>
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit">
                        <label for="uname">货到付款</label>
                    </dt>
                    <dd class="opt">
                        <label>
                            <input type="radio" name="shop[shop_open_offline]" value="0" {if condition="!isset($userConfig.shop_open_offline) || empty($userConfig.shop_open_offline)"}checked="checked"{/if}/>开启
                        </label>
                        &nbsp;&nbsp;&nbsp;
                        <label>
                            <input type="radio" name="shop[shop_open_offline]" value="1" {if condition="$userConfig.shop_open_offline == 1"}checked="checked"{/if}/>关闭
                        </label>
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit">
                        <label for="username">快递公司</label>
                    </dt>
                    <dd class="opt" style="line-height: 30px;">
                        <a href="javascript:void(0);" onclick="SelectExpress();" class="ncap-btn ncap-btn-green">设置快递公司</a>
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit">
                        <label for="username">运费模板</label>
                    </dt>
                    <dd class="opt" style="line-height: 30px;">
                        <label>
                            <input type="radio" name="shop[shop_open_shipping]" value="0" {if condition="!isset($userConfig.shop_open_shipping) || empty($userConfig.shop_open_shipping)"}checked="checked"{/if}/>包邮
                        </label>
                        &nbsp;&nbsp;&nbsp;
                        <label>
                            <input type="radio" name="shop[shop_open_shipping]" value="1" {if condition="$userConfig.shop_open_shipping == 1"}checked="checked"{/if}/>需要运费
                            &nbsp;<a id="a_shop_open_shipping" href="javascript:void(0);" onclick="SetShipping();" class="ncap-btn ncap-btn-green" {if condition="!isset($userConfig.shop_open_shipping) || empty($userConfig.shop_open_shipping)"}style="display:none;"{/if}>设置价格</a>
                        </label>
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit">
                        <label for="uname">产品类型</label>
                    </dt>
                    <dd class="opt">
                        <label>
                            <input type="radio" name="shop[shop_type]" value="0" {if condition="!isset($userConfig.shop_type) || empty($userConfig.shop_type)"}checked="checked"{/if}/>实物
                        </label>
                        &nbsp;&nbsp;&nbsp;
                        <label>
                            <input type="radio" name="shop[shop_type]" value="1" {if condition="$userConfig.shop_type == 1"}checked="checked"{/if}/>虚拟
                        </label>
                        &nbsp;&nbsp;&nbsp;
                        <label>
                            <input type="radio" name="shop[shop_type]" value="2" {if condition="$userConfig.shop_type == 2"}checked="checked"{/if}/>两者均有
                        </label>
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit">
                        <label for="username">商品规格</label>
                    </dt>
                    <dd class="opt" style="line-height: 30px;">
                        <input type="hidden" id="TestPass" name="TestPass" value="{$TestPass}">
                        <label><input type="radio" onclick="tag_call('shop_open', '{$TestPass}');" name="shop[shop_open_spec]" value="1" {if condition="$userConfig.shop_open_spec == 1"}checked="checked"{/if}/>开启</label>
                        &nbsp;&nbsp;&nbsp;
                        <label><input type="radio" name="shop[shop_open_spec]" value="0" {if condition="!isset($userConfig.shop_open_spec) || empty($userConfig.shop_open_spec)"}checked="checked"{/if}/>关闭</label>
                        <!--&nbsp;
                        <span id="a_shop_open_spec" {if condition="!isset($userConfig.shop_open_spec) || empty($userConfig.shop_open_spec)"}style="display:none;"{/if}>
                            <a href="javascript:void(0);" id='shop_open' onclick="tag_call('shop_open');" class="ncap-btn ncap-btn-green">标签调用</a>
                        </span>-->
                    </dd>
                </dl>

                <dl class="row none">
                    <dt class="tit">订单提醒</dt>
                    <dd class="opt">
                        <ul class="nc-row ncap-waybill-list">
                            <li style="width: 100%;">
                                <label class="label" onmouseover="layer_tips = layer.tips('对管理员发送邮件提醒', this, {time:100000});" onmouseout="layer.close(layer_tips);">
                                    <input class="check" type="checkbox" name="smtp_shop_order_pay" {if condition="!empty($smtp.smtp_shop_order_pay)"} value="1" checked="checked" {/if} onclick="OpenSmtp(this);"><span>管理员邮箱</span>
                                </label>
                            </li>
                        </ul>
                    </dd>
                </dl>

                <dl class="row none">
                    <dt class="tit">发货提醒</dt>
                    <dd class="opt">
                        <ul class="nc-row ncap-waybill-list">
                            <li style="width: 100%;">
                                <label class="label" onmouseover="layer_tips = layer.tips('对用户发送邮件提醒', this, {time:100000});" onmouseout="layer.close(layer_tips);">
                                    <input class="check" type="checkbox" name="smtp_shop_order_send" {if condition="!empty($smtp.smtp_shop_order_send)"} value="1" checked="checked" {/if} onclick="OpenSmtp(this);"><span>用户邮箱</span>
                                </label>
                            </li>
                        </ul>
                    </dd>
                </dl>

                <script type="text/javascript">
                    function OpenSmtp(obj) {
                        if (true == $(obj).is(':checked')) {
                            $.ajax({
                                type: "post",
                                url : "{:url('Shop/FindSmptConfig', ['_ajax'=>1])}",
                                data: {field:$(obj).attr('name')},
                                dataType: 'json',
                                success: function (res) {
                                    layer.closeAll();
                                    if(res.code == 0) {
                                        $(obj).removeAttr("checked");
                                        layer.alert(res.msg, {title:false, closeBtn:0, btn:['确认', '取消']}, function(){
                                            window.location.href = res.url;
                                        });
                                    }
                                }
                            });
                        }
                    }
                </script>
            </div>

            <div class="hDiv">
                <div class="hDivBox">
                    <table cellspacing="0" cellpadding="0" style="width: 100%">
                        <thead>
                        <tr>
                            <th class="sign w10" axis="col0">
                                <div class="tc"></div>
                            </th>
                            <th abbr="article_title" axis="col3" class="w10">
                                <div class="tc">商家收货信息</div>
                            </th>
                            <th abbr="ac_id" axis="col4">
                                <div class=""></div>
                            </th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>

            <div class="ncap-form-default">
                <dl class="row">
                    <dt class="tit">
                        <label for="addr_contact_person">联系人</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" id="addr_contact_person" style="width: 30%;" name="addr[addr_contact_person]" value="{$userConfig.addr_contact_person|default=''}"/>
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit">
                        <label for="addr_contact_phone">联系号码</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" id="addr_contact_phone" style="width: 30%;" maxlength="11" name="addr[addr_contact_phone]" value="{$userConfig.addr_contact_phone|default=''}"/>
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit">
                        <label for="addr_shipping_addr">收货地址</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" id="addr_shipping_addr" style="width: 30%;" name="addr[addr_shipping_addr]" value="{$userConfig.addr_shipping_addr|default=''}"/>
                    </dd>
                </dl>
            </div>
            
            <div class="ncap-form-default">
                <dl class="row">
                    <div class="bot">
                        <a href="JavaScript:void(0);" onclick="ShopConfig();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
                    </div>
                </dl>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">

    $(function(){
        try{
            if (typeof(eval('is_conceal_1649209614'))=="function" && is_conceal_1649209614()){
                $(".page").css("margin-left","");
                $(".page").css("min-width","");
            }else{
                $(".page").css("margin-left","98px");
                $(".page").css("min-width","auto");
            }
        }catch(e){}

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });

        $('input[name="shop[shop_open_shipping]"]').click(function() {
            var shop_open_shipping = $(this).val();
            if (1 == shop_open_shipping) {
                $('#a_shop_open_shipping').show();
            } else {
                $('#a_shop_open_shipping').hide();
            }
        });

        var ForceUse = $('#shop_force_use_wechat').val();
        if (1 == ForceUse) $('#shop_micro0').attr("disabled", "disabled");
    });

    // 设置快递公司
    function SelectExpress() {
        var url = "{:url('Shop/order_express', ['select'=>1])}";
        //iframe窗
        layer.open({
            type: 2,
            title: '设置快递公司',
            shadeClose: false,
            maxmin: false, //开启最大化最小化按钮
            area: ['60%', '80%'],
            content: url
        });
    }

    // 设置运费模板
    function SetShipping() {
        var url = "{:url('Shop/shipping_template')}";
        //iframe窗
        layer.open({
            type: 2,
            title: '运费模板管理',
            shadeClose: false,
            maxmin: false, //开启最大化最小化按钮
            area: ['60%', '80%'],
            content: url
        });
    }

    // 标签调用
    function tag_call(name, TestPass) {
        if (1 == TestPass) return false
        $.ajax({
            type: "POST",
            url: "{:url('System/ajax_tag_call', ['_ajax'=>1])}",
            data: {name:name},
            dataType: 'json',
            success: function (res) {
                if(res.code == 1){
                    //询问框
                    var layer_str = '<style type="text/css">.layui-layer-content{text-align:left!important;}</style>'+res.data.msg;
                    var confirm = layer.confirm(layer_str, {
                            title: false,
                            area: ['80%','80%'],
                            btn: ['已完成，验证下','下次再操作'],
                            cancel: function(){
                                window.location.href = "{:url('Shop/conf',['close'=>1])}";
                            }
                        }, function (){
                            VerifyLatestTemplate(name);

                        }, function(){
                            window.location.href = "{:url('Shop/conf',['close'=>1])}";
                        }
                    );  
                }else{
                    layer.alert(res.msg, {icon: 2, title:false});
                }
            },
            error:function(e){
                layer.alert(e.responseText, {icon: 2, title:false});
            }
        });
    }

    // 检测文件是否最新版
    function VerifyLatestTemplate(name, is_close) {
        layer_loading('正在处理');
        $.ajax({
            type: "POST",
            url: "{:url('Shop/VerifyLatestTemplate', ['_ajax'=>1])}",
            data: {name:name, is_close:is_close},
            dataType: 'json',
            success: function (res) {
                layer.closeAll();
                if(res.code == 1){
                    layer.msg(res.msg, {icon: 1, time:1500}, function(){
                        window.location.href = "{:url('Shop/conf')}";
                    });
                }else{
                    layer.alert(res.msg, {
                        icon: 2, 
                        title: false,
                        cancel: function(){ 
                            window.location.href = "{:url('Shop/conf')}";
                        }
                    }, function(){
                        window.location.href = "{:url('Shop/conf')}";
                    });
                }
            },
            error:function(e){
                layer.closeAll();
                layer.alert(e.responseText, {icon: 2, title:false});
            }
        });
    }

    // 判断输入框是否为空
    function ShopConfig() {
        layer_loading('正在处理');
        $('#post_form').submit();
    }
</script>
{include file="public/footer" /}